// AUTO GENERATED CODE!
// CODE GENERATOR WILL NOT PRESERVE MANUAL CHANGES TO THIS CODE!
// 

// MIT License (MIT)
// 
// Copyright (c) 2014 K Ercan Turkarslan
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// 


using System;

namespace Mios.Generated.ServiceFiles
{
    // Generated from S_Keypad1.xml
    
    public class Keypad1Service : MiosService
    {
        #region Status : Boolean;
        private Boolean? _mStatus;
        
        public Boolean Status
        {
            get
            {
                return _mStatus ?? GetStatus();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetStatus() : Boolean;
        public Boolean GetStatus()
        {
            _mStatus = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "Status"));
            
            return _mStatus.Value;
        }
        #endregion Action GetStatus
        
        #endregion
        
        #region PinCodes : String;
        private String _mPinCodes;
        
        public String PinCodes
        {
            get
            {
                return _mPinCodes ?? GetPinCodes();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetPinCodes() : String;
        public String GetPinCodes()
        {
            _mPinCodes = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "PinCodes"));
            
            return _mPinCodes;
        }
        #endregion Action GetPinCodes
        
        #endregion
        
        #region sl_UserCode : String;
        private String _msl_UserCode;
        
        public String sl_UserCode
        {
            get
            {
                return _msl_UserCode ?? Getsl_UserCode();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getsl_UserCode() : String;
        public String Getsl_UserCode()
        {
            _msl_UserCode = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "sl_UserCode"));
            
            return _msl_UserCode;
        }
        #endregion Action Getsl_UserCode
        
        #endregion
        
        #region sl_PinFailed : Boolean;
        private Boolean? _msl_PinFailed;
        
        public Boolean sl_PinFailed
        {
            get
            {
                return _msl_PinFailed ?? Getsl_PinFailed();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getsl_PinFailed() : Boolean;
        public Boolean Getsl_PinFailed()
        {
            _msl_PinFailed = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "sl_PinFailed"));
            
            return _msl_PinFailed.Value;
        }
        #endregion Action Getsl_PinFailed
        
        #endregion
        
        #region sl_CodeChanged : Int32;
        private Int32? _msl_CodeChanged;
        
        public Int32 sl_CodeChanged
        {
            get
            {
                return _msl_CodeChanged ?? Getsl_CodeChanged();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getsl_CodeChanged() : Int32;
        public Int32 Getsl_CodeChanged()
        {
            _msl_CodeChanged = FromLuupInt32(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "sl_CodeChanged"));
            
            return _msl_CodeChanged.Value;
        }
        #endregion Action Getsl_CodeChanged
        
        #endregion
        
        #region sl_LockButton : Boolean;
        private Boolean? _msl_LockButton;
        
        public Boolean sl_LockButton
        {
            get
            {
                return _msl_LockButton ?? Getsl_LockButton();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getsl_LockButton() : Boolean;
        public Boolean Getsl_LockButton()
        {
            _msl_LockButton = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "sl_LockButton"));
            
            return _msl_LockButton.Value;
        }
        #endregion Action Getsl_LockButton
        
        #endregion
        
        #region sl_LockFailure : Boolean;
        private Boolean? _msl_LockFailure;
        
        public Boolean sl_LockFailure
        {
            get
            {
                return _msl_LockFailure ?? Getsl_LockFailure();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getsl_LockFailure() : Boolean;
        public Boolean Getsl_LockFailure()
        {
            _msl_LockFailure = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "sl_LockFailure"));
            
            return _msl_LockFailure.Value;
        }
        #endregion Action Getsl_LockFailure
        
        #endregion
        
        #region sl_UnauthUser : String;
        private String _msl_UnauthUser;
        
        public String sl_UnauthUser
        {
            get
            {
                return _msl_UnauthUser ?? Getsl_UnauthUser();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getsl_UnauthUser() : String;
        public String Getsl_UnauthUser()
        {
            _msl_UnauthUser = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "sl_UnauthUser"));
            
            return _msl_UnauthUser;
        }
        #endregion Action Getsl_UnauthUser
        
        #endregion
        
        #region sl_LowBattery : Boolean;
        private Boolean? _msl_LowBattery;
        
        public Boolean sl_LowBattery
        {
            get
            {
                return _msl_LowBattery ?? Getsl_LowBattery();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getsl_LowBattery() : Boolean;
        public Boolean Getsl_LowBattery()
        {
            _msl_LowBattery = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "sl_LowBattery"));
            
            return _msl_LowBattery.Value;
        }
        #endregion Action Getsl_LowBattery
        
        #endregion
        
        #region sl_VeryLowBattery : Boolean;
        private Boolean? _msl_VeryLowBattery;
        
        public Boolean sl_VeryLowBattery
        {
            get
            {
                return _msl_VeryLowBattery ?? Getsl_VeryLowBattery();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getsl_VeryLowBattery() : Boolean;
        public Boolean Getsl_VeryLowBattery()
        {
            _msl_VeryLowBattery = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "sl_VeryLowBattery"));
            
            return _msl_VeryLowBattery.Value;
        }
        #endregion Action Getsl_VeryLowBattery
        
        #endregion
        
        #region dateTime : DateTime;
        private DateTime? _mdateTime;
        
        public DateTime dateTime
        {
            get
            {
                return _mdateTime ?? GetdateTime();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetdateTime() : DateTime;
        public DateTime GetdateTime()
        {
            _mdateTime = FromLuupDateTime(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "dateTime"));
            
            return _mdateTime.Value;
        }
        #endregion Action GetdateTime
        
        #endregion
        
        #region ui4 : UInt32;
        private UInt32? _mui4;
        
        public UInt32 ui4
        {
            get
            {
                return _mui4 ?? Getui4();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getui4() : UInt32;
        public UInt32 Getui4()
        {
            _mui4 = FromLuupUInt32(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "ui4"));
            
            return _mui4.Value;
        }
        #endregion Action Getui4
        
        #endregion
        
        #region ui1 : Byte;
        private Byte? _mui1;
        
        public Byte ui1
        {
            get
            {
                return _mui1 ?? Getui1();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action Getui1() : Byte;
        public Byte Getui1()
        {
            _mui1 = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "ui1"));
            
            return _mui1.Value;
        }
        #endregion Action Getui1
        
        #endregion
        
        #region Target : String;
        // WARNING: This state variable was not defined in the Service Description file.
        // However it was referenced by one or more Actions as their related state variable.
        // Or it was returned by Vera in USER_DATA xml.
        // This may be due to a typo in RelatedStateVariable definition or missing State Variable.
        
        private String _mTarget;
        
        public String Target
        {
            get
            {
                return _mTarget ?? GetTarget();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetTarget() : String;
        public String GetTarget()
        {
            _mTarget = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "Target"));
            
            return _mTarget;
        }
        #endregion Action GetTarget
        
        #endregion
        
        
        #region Action SetPin(String json, String userCodeName, String newPin, UInt32? userCode) : UInt32;
        public UInt32 SetPin(String json, String userCodeName, String newPin, UInt32? userCode)
        {
            // WARNING: This version of code generator does not know how to generate Http Luup requests with out variables.
            // Below generated code may not function properly!
            // 
            
            return FromLuupUInt32(
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetPin"
                , json == null ? "" : String.Format("json={0}", ToLuup(json))
                , userCodeName == null ? "" : String.Format("UserCodeName={0}", ToLuup(userCodeName))
                , newPin == null ? "" : String.Format("newPin={0}", ToLuup(newPin))
                )); // Engine.Luup_CallAction
        }
        #endregion Action SetPin
        
        #region Action SetPinValidityDate(UInt32 userCode, DateTime? startDate, DateTime? stopDate, String replace, UInt32 slotID) : UInt32;
        public UInt32 SetPinValidityDate(UInt32 userCode, DateTime? startDate, DateTime? stopDate, String replace, UInt32 slotID)
        {
            // WARNING: This version of code generator does not know how to generate Http Luup requests with out variables.
            // Below generated code may not function properly!
            // 
            
            return FromLuupUInt32(
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetPinValidityDate"
                , String.Format("UserCode={0}", ToLuup(userCode))
                , startDate == null ? "" : String.Format("StartDate={0}", ToLuup(startDate))
                , stopDate == null ? "" : String.Format("StopDate={0}", ToLuup(stopDate))
                , replace == null ? "" : String.Format("Replace={0}", ToLuup(replace))
                )); // Engine.Luup_CallAction
        }
        #endregion Action SetPinValidityDate
        
        #region Action SetPinValidityWeekly(UInt32 userCode, UInt32? dayOfWeek, Byte? startHour, Byte? startMinute, Byte? stopHour, Byte? stopMinute, String replace, UInt32 slotID) : UInt32;
        public UInt32 SetPinValidityWeekly(UInt32 userCode, UInt32? dayOfWeek, Byte? startHour, Byte? startMinute, Byte? stopHour, Byte? stopMinute, String replace, UInt32 slotID)
        {
            // WARNING: This version of code generator does not know how to generate Http Luup requests with out variables.
            // Below generated code may not function properly!
            // 
            
            return FromLuupUInt32(
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetPinValidityWeekly"
                , String.Format("UserCode={0}", ToLuup(userCode))
                , dayOfWeek == null ? "" : String.Format("DayOfWeek={0}", ToLuup(dayOfWeek))
                , startHour == null ? "" : String.Format("StartHour={0}", ToLuup(startHour))
                , startMinute == null ? "" : String.Format("StartMinute={0}", ToLuup(startMinute))
                , stopHour == null ? "" : String.Format("StopHour={0}", ToLuup(stopHour))
                , stopMinute == null ? "" : String.Format("StopMinute={0}", ToLuup(stopMinute))
                , replace == null ? "" : String.Format("Replace={0}", ToLuup(replace))
                )); // Engine.Luup_CallAction
        }
        #endregion Action SetPinValidityWeekly
        
        #region Action ClearPinValidity(UInt32 userCode, UInt32 slotID)
        public void ClearPinValidity(UInt32 userCode, UInt32 slotID)
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "ClearPinValidity"
                , String.Format("UserCode={0}", ToLuup(userCode))
                , String.Format("slotID={0}", ToLuup(slotID))
                ); // Engine.Luup_CallAction
        }
        #endregion Action ClearPinValidity
        
        #region Action ClearPin(String userCode)
        public void ClearPin(String userCode)
        {
            if (String.IsNullOrEmpty(userCode))
                throw new ArgumentNullException("userCode");
            
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "ClearPin"
                , String.Format("UserCode={0}", ToLuup(userCode))
                ); // Engine.Luup_CallAction
        }
        #endregion Action ClearPin
        
        
        #region Method SetVariable(String name, String value) : Boolean;
        internal override Boolean SetVariable(String name, String value)
        {
            switch(name)
            {
                case "dateTime":
                    _mdateTime = FromLuupDateTime(value); return true;
                case "PinCodes":
                    _mPinCodes = FromLuupString(value); return true;
                case "sl_CodeChanged":
                    _msl_CodeChanged = FromLuupInt32(value); return true;
                case "sl_LockButton":
                    _msl_LockButton = FromLuupBoolean(value); return true;
                case "sl_LockFailure":
                    _msl_LockFailure = FromLuupBoolean(value); return true;
                case "sl_LowBattery":
                    _msl_LowBattery = FromLuupBoolean(value); return true;
                case "sl_PinFailed":
                    _msl_PinFailed = FromLuupBoolean(value); return true;
                case "sl_UnauthUser":
                    _msl_UnauthUser = FromLuupString(value); return true;
                case "sl_UserCode":
                    _msl_UserCode = FromLuupString(value); return true;
                case "sl_VeryLowBattery":
                    _msl_VeryLowBattery = FromLuupBoolean(value); return true;
                case "Status":
                    _mStatus = FromLuupBoolean(value); return true;
                case "Target":
                    _mTarget = FromLuupString(value); return true;
                case "ui1":
                    _mui1 = FromLuupByte(value); return true;
                case "ui4":
                    _mui4 = FromLuupUInt32(value); return true;
                default:
                    return false;
            }
        }
        #endregion Method SetVariable
        
        public Keypad1Service(MiosEngine engine, UInt32 deviceId, String serviceId)
            : base(engine, deviceId, serviceId)
        {
            
        } //End Constructor
    } //End of class
} //End of Namespace

